package com.dingwei.superiordiary.mvp.presenter;

import android.text.TextUtils;

import com.dingwei.superiordiary.base.MyBaseBean;
import com.dingwei.superiordiary.bean.FailsBean;
import com.dingwei.superiordiary.custom.myCallback;
import com.dingwei.superiordiary.mvp.view.Contract;
import com.lihao.baselibrary.base.BaseActivity;
import com.lihao.baselibrary.base.URLS;
import com.lihao.baselibrary.base.basePresenter;

import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * Created by lihao on 2017/9/12.
 */

public class FeedbackPresenter extends basePresenter {

    private Contract.FeedbackView feedbackView;

    public FeedbackPresenter(Contract.FeedbackView view) {
        super(view);
        this.feedbackView = view;
    }

    public void feedback(String content) {
        if (TextUtils.isEmpty(content)){
            showToast("请输入您的意见或者建议！");
            return;
        }
        RequestParams rp = new RequestParams(URLS.HOST+URLS.FEEDBACK);
        rp.addBodyParameter("sessionid", BaseActivity.value.getToken());
        rp.addBodyParameter("content",content);
        x.http().post(rp, new myCallback(BaseActivity.context, MyBaseBean.class, rp) {
            @Override
            public void back(MyBaseBean baseBean, String result) {
                showToast(baseBean.message);
                feedbackView.feedbackSuccess();
            }

            @Override
            public void fail(FailsBean baseBean, String result) {
            }
        });
    }

}
